Telegram Group & Telegram Channel
⚡️ Фича дня: условный оператор с инициализацией

Часто перед условным оператором нужно объявить временную переменную, что загромождает область видимости и увеличивает вероятность ошибок.

Инициализация переменных прямо в условии if/switch (C++17) позволяет ограничить область видимости только блоком условия.

🔴 До:
auto it = map.find(key);
if (it != map.end()) {
// Используем it->second
}


🟢 После:
if (auto it = map.find(key); it != map.end()) {
// Используем it->second
}


Примеры использования:

- Поиск в контейнерах с проверкой результата
- Вызов функций с проверкой возвращаемого значения
- Инициализация мьютексов с последующей блокировкой

💡 Как думаете, улучшает ли это читаемость кода?

Библиотека C/C++ разработчика #буст



tg-me.com/cppproglib/5674
Create:
Last Update:

⚡️ Фича дня: условный оператор с инициализацией

Часто перед условным оператором нужно объявить временную переменную, что загромождает область видимости и увеличивает вероятность ошибок.

Инициализация переменных прямо в условии if/switch (C++17) позволяет ограничить область видимости только блоком условия.

🔴 До:

auto it = map.find(key);
if (it != map.end()) {
// Используем it->second
}


🟢 После:
if (auto it = map.find(key); it != map.end()) {
// Используем it->second
}


Примеры использования:

- Поиск в контейнерах с проверкой результата
- Вызов функций с проверкой возвращаемого значения
- Инициализация мьютексов с последующей блокировкой

💡 Как думаете, улучшает ли это читаемость кода?

Библиотека C/C++ разработчика #буст

BY Библиотека C/C++ разработчика | cpp, boost, qt


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/cppproglib/5674

View MORE
Open in Telegram


Библиотека C C разработчика | cpp boost qt Telegram | DID YOU KNOW?

Date: |

Among the actives, Ascendas REIT sank 0.64 percent, while CapitaLand Integrated Commercial Trust plummeted 1.42 percent, City Developments plunged 1.12 percent, Dairy Farm International tumbled 0.86 percent, DBS Group skidded 0.68 percent, Genting Singapore retreated 0.67 percent, Hongkong Land climbed 1.30 percent, Mapletree Commercial Trust lost 0.47 percent, Mapletree Logistics Trust tanked 0.95 percent, Oversea-Chinese Banking Corporation dropped 0.61 percent, SATS rose 0.24 percent, SembCorp Industries shed 0.54 percent, Singapore Airlines surrendered 0.79 percent, Singapore Exchange slid 0.30 percent, Singapore Press Holdings declined 1.03 percent, Singapore Technologies Engineering dipped 0.26 percent, SingTel advanced 0.81 percent, United Overseas Bank fell 0.39 percent, Wilmar International eased 0.24 percent, Yangzijiang Shipbuilding jumped 1.42 percent and Keppel Corp, Thai Beverage, CapitaLand and Comfort DelGro were unchanged.

How Does Bitcoin Work?

Bitcoin is built on a distributed digital record called a blockchain. As the name implies, blockchain is a linked body of data, made up of units called blocks that contain information about each and every transaction, including date and time, total value, buyer and seller, and a unique identifying code for each exchange. Entries are strung together in chronological order, creating a digital chain of blocks. “Once a block is added to the blockchain, it becomes accessible to anyone who wishes to view it, acting as a public ledger of cryptocurrency transactions,” says Stacey Harris, consultant for Pelicoin, a network of cryptocurrency ATMs. Blockchain is decentralized, which means it’s not controlled by any one organization. “It’s like a Google Doc that anyone can work on,” says Buchi Okoro, CEO and co-founder of African cryptocurrency exchange Quidax. “Nobody owns it, but anyone who has a link can contribute to it. And as different people update it, your copy also gets updated.”

Библиотека C C разработчика | cpp boost qt from tr


Telegram Библиотека C/C++ разработчика | cpp, boost, qt
FROM USA